<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@ include file="/jsp/head.jsp"%>
	
	<%@ include file="/jsp/jslib.jsp"%>
	<script type="text/javascript">
	PAGE_CONFIG = {
		'MENU_INDEX' : 1,'LI_INDEX' : 3
	};
	</script>
	<link rel="stylesheet" href="${ctx}/css/project.css" >
	<script type="text/javascript" src="${ctx}/js/project.js"></script>
	<script type="text/javascript">
	$(function(){
		project.ctx = "${ctx}";
		if("" != $('#error').val()){
			var $modal1 = $('#my-alert');
			$modal1.modal();
		}
		project.initRate();
	});
	
	function getPartnerProductAndContact(o) {
		//查询该供应商产品
		$.ajax({
	        type: "POST",
	        async:false,
	        url: '${ctx}/partner/product/getlistbycompanyid',
	        data : {
	        	"partnerCompanyId" : o.find("option:selected").val(),
	        },
	        success: function(list) {
	        	var select = o.parent().next().children("#partnerProductId")[0];
	        	$(select).html("");
	        	
	        	var option = '<option value="">请选择</option>';
	        	$(select).append(option);
	        	
	        	$.each(list, function(index, value){
					var id     = value.partnerProductId;
					var name   = value.partnerProductName;
					var option = '<option value="' + id + '">' + name + '</option>';
					$(select).append(option);
	        	});
	        }
	    });
		
		//查询该供应商联系人
		$.ajax({
	        type: "POST",
	        async:false,
	        url: '${ctx}/partner/contact/getlistbycompanyid',
	        data : {
	        	"partnerCompanyId" : o.find("option:selected").val(),
	        },
	        success: function(list) {
	        	var select = o.parent().next().next().children("#partnerContactId")[0];
	        	$(select).html("");
	        	
	        	var option = '<option value="">请选择</option>';
	        	$(select).append(option);
	        	
	        	$.each(list, function(index, value){
					var id     = value.contactId;
					var name   = value.contactName;
					var option = '<option value="' + id + '">' + name + '</option>';
					$(select).append(option);
	        	});
	        }
	    });
	};
	
	//修改客户公司要及时更新客户联系人  做联动
	function updateCustomer() {
		var selected = $('#customerCompany option:selected').val();
		
		$.ajax({
	        type: "POST",
	        async:false,
	        url: "project/getCompanyList",
	        data : {
	        	"companyId":selected
	        },
	        success: function(list) {
	        	if(list != null && list.length != 0) {
	        		var customerId = $("#customer");
	            	$("option", customerId).remove(); //清空原有的选项 
	            	
	            	$.each(list, function(index, map) {
	                    var option = "<option value='" + map.id + "'>" + map.name + "</option>";
	                    customerId.append(option);
	                });
	        	}
	        }
	    });
	};
	</script>
	
</head>
<body>

<%@ include file="/jsp/banner.jsp"%>
<div class="am-cf admin-main">
	<%@ include file="/jsp/menu.jsp"%>
	
	<!-- content start -->
	<div class="admin-content">
		<div class="admin-content-body">
		
		<!-- ***** 分离出去 动态加载 start ***** -->
		
		<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
      <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">编辑执行项目详细信息</strong>
      </div>
    </div>

    <hr>

    <div class="am-tabs am-margin" data-am-tabs>
      <ul class="am-tabs-nav am-nav am-nav-tabs"></ul>

      <div class="am-tabs-bd">

        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
          <form id="implProjectForm" action="${ctx}/project/updateImplProjectAdmin" method="post" class="am-form">
           
            <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">项目名称</div>
              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">${project.projectName}</div>
            </div>

			<div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">客户公司</div>
              <div class="am-u-sm-8 am-u-md-10">
                <select data-am-selected="{btnSize:'sm'}" id="customerCompany" name="customerCompany" onchange="updateCustomer()">
                  	<c:forEach items="${customerCompanyList }" var = "customerCompany" >
           				<option value="${customerCompany.customerCompanyId }" <c:if test="${customerCompany.customerCompanyId == project.customerCompanyId}">selected</c:if>>${customerCompany.customerCompanyName }</option>
           			</c:forEach>
                </select>
              </div>
            </div>
          
	          <div class="am-g am-margin-top">
				  <div class="am-u-sm-4 am-u-md-2 am-text-right" >客户负责人</div>
				  <div class="am-u-sm-8 am-u-md-10">
				    <select data-am-selected="{btnSize:'sm'}" id="customer" name="customer">
				    	<option value="">请选择</option> 
						<c:forEach items="${customerList }" var = "customer" >
							<option value="${customer.customerId }" <c:if test="${customer.customerId == project.customerId}">selected</c:if>>${customer.customerName }</option>
						</c:forEach>
				    </select>
				  </div>
				</div>
          
          
	          <div class="am-g am-margin-top">
				  <div class="am-u-sm-4 am-u-md-2 am-text-right">接单部门</div>
				  <div class="am-u-sm-8 am-u-md-10">
				    <select data-am-selected="{btnSize:'sm'}" id="company" name="company">
				    	<option value="">请选择</option> 
						<c:forEach items="${companyList }" var = "company" >
							<option value="${company.companyId }" <c:if test="${company.companyId == project.companyId}">selected</c:if>>${company.companyName }</option>
						</c:forEach>
				    </select>
				  </div>
				</div>

			
	          <div class="am-g am-margin-top">
				  <div class="am-u-sm-4 am-u-md-2 am-text-right">项目负责人</div>
				  <div class="am-u-sm-8 am-u-md-10">
				    <select data-am-selected="{btnSize: 'sm'}" id="staff" name="staff">
				    	<option value="">请选择</option> 
						<c:forEach items="${staffList }" var = "staff" >
							<option value="${staff.staffId }" <c:if test="${staff.staffId == project.staffId}">selected</c:if>>${staff.staffName }</option>
						</c:forEach>
				    </select>
				  </div>
				</div>
				
			  <div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">项目进度</div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	              	<select data-am-selected="{btnSize:'sm'}" name="projectSchedule" id="projectSchedule" >
				    	<option value="">请选择</option>
				    	 <c:forEach items="${projectSchedule }" var = "projectSchedule" >
							<option value="${projectSchedule.value}" <c:if test="${projectSchedule.value == project.projectSchedule}">selected</c:if>>${projectSchedule.value}</option>
						</c:forEach>
				    </select>
	              </div>
	            </div>
	            
	            <div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">报价</div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	                <input type="text" class="am-input-sm" name="offer" id="offer"  value="${project.offer}" >
	              </div>
	            </div>
	            
	            <div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">合同编码</div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	                <input type="text" class="am-input-sm" value="${contract.contractCode}" disabled>
	              	<input type="hidden" class="am-input-sm" name="contractCode" id="contractCode"  value="${contract.contractCode}" >
	              </div>
	            </div>
			
            <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right"> 运维维护 </div>
              <div class="am-u-sm-8 am-u-md-10 am-u-end col-end "> 
             	<label class="am-radio ">
			      <input type="radio" name="isRepair" id="isRepair" value="Y" data-am-ucheck <c:if test="${'Y' == project.isRepair }">checked</c:if> >
			      	有运维
			    </label>
			    <label class="am-radio">
			      <input type="radio" name="isRepair" id="isNotRepair" value="N" data-am-ucheck <c:if test="${'N' == project.isRepair || null== project.isRepair}">checked</c:if>>
			      	无运维
			    </label>
			    <div id="repair" <c:if test="${'N' == project.isRepair || null== project.isRepair}">style="display: none;"</c:if>>
				    <div class="am-u-md-2 am-u-end"> 运维开始时间</div>
				    <div class="am-u-md-3"> 
				    	<input type="date" class="am-form-field am-input-sm" name="repairStartDate" id="repairStartDate" 
				    	placeholder="时间" value="<fmt:formatDate value='${project.repairStartDate}' pattern='yyyy-MM-dd'/>">
				    </div>
				    <div class="am-u-md-2"> 运维结束时间</div>
				    <div class="am-u-md-3 am-u-end col-end ">
				    	<input type="date" class="am-form-field am-input-sm" name="repairEndDate" id="repairEndDate"
				    	 placeholder="时间" value="<fmt:formatDate value='${project.repairEndDate}' pattern='yyyy-MM-dd'/>">
				    </div>
			    </div>
              </div>
	        </div>
            
            <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right"> 供应商 </div>
	            <div class="am-u-sm-8 am-u-md-10">
		        	
		        	
		        	<!-- <button type="button" onclick="project.addPartnerCompany(this)" class="am-btn am-btn-default"><span class="am-icon-plus"></span>添加供应商</button>
		        	<table id = "partnerTable" class="am-table am-table-bd am-table-striped admin-content-table">
		        		<tr>
		        			<td>供应商</td>
		        			<td></td>
		        		</tr>
		        	</table> -->
		        	
	        		<button type="button" onclick="project.addPartnerCompany(this)" class="am-btn am-btn-default"><span class="am-icon-plus"></span>添加供应商</button>
					<table id="partnerCompanyTable" class="am-table am-table-bd am-table-striped admin-content-table">
						<thead>
				            <tr>
				              <td hidden>ID</td>
				              <th></th>
				              <th></th>
				              <th></th>
				              <th></th>
				            </tr>
			            </thead>
						<tbody>
							<c:forEach var="partner" items="${partnerList}" varStatus="s">
								<tr>
									<td hidden>${partner.partnerCompanyId}</td>
									<td width="40%">
										<!-- 供应商 -->
										<select id="partnerCompanyId" name="partnerCompanyId" onchange="getPartnerProductAndContact($(this))">
											<option value="">请选择</option>
											<c:forEach items="${partnerCompanyList}" var = "partnerCompany" >
												<option value="${partnerCompany.partnerCompanyId}" <c:if test="${partner.partnerCompanyId == partnerCompany.partnerCompanyId}">selected</c:if>>${partnerCompany.partnerCompanyName}</option>
											</c:forEach>
										</select>
									</td>
									<td width="25%">
										<!-- 产品/服务 -->
										<select id="partnerProductId" name="partnerProductId">
											<option value="">请选择</option>
											<c:forEach items="${partner.partnerProductList}" var = "partnerProduct" >
												<option value="${partnerProduct.partnerProductId}" <c:if test="${partner.partnerProductId == partnerProduct.partnerProductId}">selected</c:if>>${partnerProduct.partnerProductName}</option>
											</c:forEach>
										</select>
									</td>
									<td width="25%">
										<!-- 供应商联系人 -->
										<select id="partnerContactId" name="partnerContactId">
											<option value="">请选择</option>
											<c:forEach items="${partner.partnerContactList}" var = "partnerContact" >
												<option value="${partnerContact.contactId}" <c:if test="${partner.partnerContactId == partnerContact.contactId}">selected</c:if>>${partnerContact.contactName}</option>
											</c:forEach>
										</select>
									</td>
									<td width="10%">
										<button name="removeTr" onclick="$(this).parent().parent().remove();" type="button" class="am-btn am-btn-default am-btn-sm">删除</button>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
		        	
		        	<table id="partnerTable" class="am-table am-table-bd am-table-striped admin-content-table am-text-nowrap"><!-- am-table-compact -->
			        	<thead>
				        	<tr>
			        			<th hidden>ID</th>
			       				<th>&nbsp;供应商&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
			       				<th>出货</th>
			       				<th>出货日期</th>
				            	<th>开票</th>
				            	<th>开票类型</th>
				            	<th>开票日期</th>
				            	<th>付款</th>
				            	<th>付款日期</th>
				            </tr>
			            </thead>
			            <tbody>
			            	<c:forEach var="partnerDetail" items="${partnerDetailList}" varStatus="s">
    				            <tr>
    				            	<!-- 供应商ID -->
    				            	<td hidden>
    				            		<input type="hidden" name="partnerDetailId" value="${partnerDetail.partnerDetailId}" />
    				            		<input type="hidden" name="partnerCompanyId" value="${partnerDetail.partnerCompanyId}" />
    				            	</td>
    				            	<!-- 供应商 -->
    				            	<td ><input type="text" name="partnerCompanyName" class="am-input-sm" value="${partnerDetail.partnerCompanyName}"></td>
    				            	<!-- 出货 -->
    				            	<td>
						            	<label class="am-checkbox">
									      <input type="checkbox" name="isShipment" value="${partnerDetail.isShipment}" ${partnerDetail.isShipment == 'Y' ? 'checked' : ''} data-am-ucheck>
									    </label>
									</td>
									<!-- 出货日期 -->
									<td>
					            		<input type="date" class="am-form-field am-input-sm" name="shipmentDate" 
					            			placeholder="时间" value="<fmt:formatDate value='${partnerDetail.shipmentDate}' pattern='yyyy-MM-dd'/>">
									</td>
									<!-- 开票 -->
									<td>
						            	<label class="am-checkbox">
									      <input type="checkbox" name="isBilling" value="${partnerDetail.isBilling}" ${partnerDetail.isBilling == 'Y' ? 'checked' : ''} data-am-ucheck>
									    </label>
									</td>
									<!-- 开票类型 -->
									<td>
					            		<select data-am-selected="{btnSize: 'sm'}"  name="billingType" id="billingType" >
							                <option value="" >请选择</option>
							                <c:forEach items="${billingTypeMap }" var = "billing" >
						           				<option value="${billing.key }" <c:if test="${billing.key == partnerDetail.billingType}">selected</c:if>>${billing.value}</option>
						           			</c:forEach>
							             </select>
									</td>
									<!-- 开票日期 -->
									<td>
					            		<input type="date" class="am-form-field am-input-sm" name="billingDate" 
					            			placeholder="时间" value="<fmt:formatDate value='${partnerDetail.billingDate}' pattern='yyyy-MM-dd'/>">
									</td>
									<!-- 付款 -->
									<td>
						            	<label class="am-checkbox">
									      <input type="checkbox" name="isPayment" value="${partnerDetail.isPayment}" ${partnerDetail.isPayment == 'Y' ? 'checked' : ''} data-am-ucheck>
									    </label>
									</td>
									<!-- 付款日期 -->
									<td>
					            		<input type="date" class="am-form-field am-input-sm" name="paymentDate" 
					            			placeholder="时间" value="<fmt:formatDate value='${partnerDetail.paymentDate}' pattern='yyyy-MM-dd'/>">
									</td>
    				            </tr>
    				        </c:forEach>
			            </tbody>
		          	</table>
		        </div>
			</div>
			
			<%-- <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right"> 合同 </div>
	            <div class="am-u-sm-8 am-u-md-6 am-u-end col-end"> 
					<div class="am-u-md-4">
						<label class="am-checkbox-inline"><input type="checkbox" name="isSign" onclick="project.changeCheckbox(this);" value="${contract.isSign}" ${contract.isSign == 'Y' ? 'checked' : ''} data-am-ucheck >签订 </label>
						<label class="am-checkbox-inline"><input type="checkbox" name="isDelivery" onclick="project.changeCheckbox(this);" value="${contract.isDelivery}" ${contract.isDelivery == 'Y' ? 'checked' : ''} data-am-ucheck >交货</label>
					</div>
				    
				    <div class="am-u-md-3">签订日期</div>
				    <div class="am-u-md-5"><input type="date" name="signDate" value="<fmt:formatDate value='${contract.signDate}' pattern='yyyy-MM-dd'/>" class="am-form-field am-input-sm" placeholder="时间">
				    </div>
	            </div>
	            <div class="am-u-sm-12 am-u-md-4 am-u-end col-end"> 
				    <button type="button" onclick="project.addBillingContractDetail(this)" class="am-btn am-btn-default">
				    	<span class="am-icon-plus"></span>添加开票明细
				    </button>
				    &nbsp;
				    <button type="button" onclick="project.addPaymentContractDetail(this)" class="am-btn am-btn-default">
				    	<span class="am-icon-plus"></span>添加收款明细
				    </button>
	            </div>
	            
			</div> --%>
			
			<div class="am-g am-margin-top">	 
			  	<div class="am-u-sm-4 am-u-md-2 am-text-right"> 合同 </div> 
			  	<div class="am-u-sm-8 am-u-md-8 am-u-end col-end"> 
					<div class="am-u-sm-8 am-u-md-2 ">
						<label class="am-checkbox-inline">
							<input type="checkbox" name="isSign" onclick="project.changeCheckbox(this);" value="${contract.isSign}" ${contract.isSign == 'Y' ? 'checked' : ''} data-am-ucheck >签订 
						</label>
					</div>
					<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
						<div class="am-u-sm-8 am-u-md-4 ">签订日期:</div>
						<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
							<input type="date" name="signDate" value="<fmt:formatDate value='${contract.signDate}' pattern='yyyy-MM-dd'/>" class="am-form-field am-input-sm" placeholder="时间">
						</div>
					</div>
				</div>
			</div>
			<div class="am-g am-margin-top">
				<div class="am-u-sm-4 am-u-md-2 am-text-right">&nbsp;</div>
				<div class="am-u-sm-8 am-u-md-8 am-u-end col-end"> 
					<div class="am-u-sm-8 am-u-md-2 ">
						<label class="am-checkbox-inline">
							<input type="checkbox" name="isDelivery" onclick="project.changeCheckbox(this);" value="${contract.isDelivery}" ${contract.isDelivery == 'Y' ? 'checked' : ''} data-am-ucheck >交货 
						</label>
					</div>
					<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
						<div class="am-u-sm-8 am-u-md-4 ">交货日期:</div>
						<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
							<input type="date" name="deliveryDate" value="<fmt:formatDate value='${contract.deliveryDate}' pattern='yyyy-MM-dd'/>" class="am-form-field am-input-sm" placeholder="时间">
						</div>
					</div>
				</div>
			</div>
			<div class="am-g am-margin-top">
				<div class="am-u-sm-4 am-u-md-2 am-text-right">&nbsp;</div>
				<div class="am-u-sm-8 am-u-md-8 am-u-end col-end"> 
					<button type="button" onclick="project.addBillingContractDetail(this)" class="am-btn am-btn-default">
				    	<span class="am-icon-plus"></span>添加开票明细
				    </button>
					&nbsp;
					<button type="button" onclick="project.addPaymentContractDetail(this)" class="am-btn am-btn-default">
						<span class="am-icon-plus"></span>添加收款明细
					</button>
				</div>
			</div>
			
			<div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right"> </div>
	            <div class="am-u-sm-8 am-u-md-10">
		             <table id="contractBillingDetailTable" class="am-table am-table-bd am-table-striped admin-content-table">
			            <thead>
				            <tr>
				              <th hidden>ID</th>
				              <th>开票</th>
				              <th><div class="am-u-md-8">开票类型</div></th>
				              <th><div class="am-u-md-12">预定开票日期</div></th>
				              <th><div class="am-u-md-12">开票金额</div></th>
				              <th><div class="am-u-md-12">开票比例(%)</div></th>
				            </tr>
			            </thead>
			            <tbody>
				            <c:forEach var="contractDetail" items="${contractBillingDetailList}" varStatus="s">
	    				        <tr x-update>
				            	<td hidden>
				            		<input type="hidden" name="contractDetailId" value="${contractDetail.contractDetailId}" />
				            	</td>
				            	<td>
				            		<label class="am-checkbox">
								      <input type="checkbox" name="isBilling" value="${contractDetail.isBilling}" ${contractDetail.isBilling == 'Y' ? 'checked' : ''} data-am-ucheck >
								    </label>
								</td>
								<td>
									<select data-am-selected="{btnSize: 'sm',dropUp: 1}" name="billingType">
						                <option value="">请选择</option> 
						                <c:forEach items="${billingTypeMap}" var = "billing" >
					           				<option value="${billing.key }" <c:if test="${billing.key == contractDetail.billingType}">selected</c:if>>${billing.value}</option>
					           			</c:forEach>
						            </select>
					            </td>
				            	<td>
				            		<div class="am-u-md-12">
				            			<input type="date" name="billingDate" class="am-form-field am-input-sm" value="<fmt:formatDate value='${contractDetail.billingDate}' pattern='yyyy-MM-dd'/>" placeholder="时间">
				            		</div>
				            	</td>
				            	<td>
				            		<div class="am-u-md-12">
				            			<input type="number" name="billingMoney" class="am-input-sm" value="${contractDetail.billingMoney}" placeholder="请输入数字" >
				            		</div>
				            	</td>
				            	<td>
				            		<div class="am-u-md-10">
				            			<input type="text" name="billingRate" class="am-input-sm" value="${contractDetail.billingRate}" disabled>
				            		</div>
				            	</td>  
				            	</tr>
				            </c:forEach>
			            </tbody>
		          	</table>
		        </div>
		        
	        </div>
	        <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">  </div>
		        <div class="am-u-sm-8 am-u-md-10">
		             <table id="contractPaymentDetailTable" class="am-table am-table-bd am-table-striped admin-content-table">
			            <thead>
				            <tr>
				              <th hidden>ID</th>
				              <th>收款</th>
				              <th><div class="am-u-md-10">预定收款日期</div></th>
				              <th><div class="am-u-md-10">收款比例（%）</div></th>
				            </tr>
			            </thead>
			            <tbody>
				            <c:forEach var="contractDetail" items="${contractPaymentDetailList}" varStatus="s">
	    				        <tr x-update>
				            	<td hidden>
				            		<input type="hidden" name="contractDetailId" value="${contractDetail.contractDetailId}" />
				            	</td>
				            	<td>
				            		<label class="am-checkbox">
								      <input type="checkbox" name="isPayment" value="${contractDetail.isPayment}" ${contractDetail.isPayment == 'Y' ? 'checked' : ''} data-am-ucheck >
								    </label>
								</td>
				              	<td>
				              		<div class="am-u-md-10">
				            			<input type="date" name="paymentDate" class="am-form-field am-input-sm" value="<fmt:formatDate value='${contractDetail.paymentDate}' pattern='yyyy-MM-dd'/>" placeholder="时间">
				            		</div>
				              	</td>
				              	<td>
				            		<div class="am-u-md-10">
				            			<input type="text" name="paymentRate" class="am-input-sm" value="${contractDetail.paymentRate}" >
				            		</div>
				            	</td>
				            </tr>
				            </c:forEach>
			            </tbody>
		          	 </table>
			    </div>
			
			</div>
			
			<div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">已完成事项 </div>
	            <div class="am-u-sm-8 am-u-md-10">
		             <table id="logTable2" class="am-table am-table-bd am-table-striped admin-content-table">
			            <thead>
				            <tr>
				              <td hidden>ID</td>
				              <th>完成事项</th>
				              <th><div class="am-u-md-8">完成日期</div></th>
				            </tr>
			            </thead>
			            <tbody>
			            	<c:forEach var="projectLog" items="${projectLogList2}" varStatus="s">
			            		<tr x-update>
			            			<!-- 完成事项 -->
			            			<td>
			            				<textarea id="todoSomething" name="todoSomething" class="am-input-sm" rows="1">${projectLog.todoSomething}</textarea>
			            			</td>
					            	<!-- 完成日期 -->
					            	<td>
										<div class="am-u-md-8">
					              			<input type="date" name="todoDate" class="am-form-field am-input-sm" 
					              				placeholder="时间" value="<fmt:formatDate value='${projectLog.todoDate}' pattern='yyyy-MM-dd'/>" disabled>
					              		</div>
									</td> 
			            		</tr>
			            	</c:forEach>
			            </tbody>
		          	</table>
		        </div>
			</div>
	      		
      		<div class="am-g am-margin-top">
      			<div class="am-u-sm-4 am-u-md-2 am-text-right">备注</div>
	            <div class="am-u-sm-8 am-u-md-10">
      				<textarea id="note" name="note" class="am-input-sm" rows="5">${project.note}</textarea>
     				</div>
      		</div>
			
			
				<input type="hidden" name="contractId" id="contractId" value="${contract.contractId}">
				<input type="hidden" name="projectId" id="projectId" value="${project.projectId}">
				<!-- flag=1代表只是保存，flag=2代表确认立项（流转到项目执行），flag=4表示流转项目完成 -->
				<!-- <input type="hidden" name="flag" id="flag" > -->
				<input type="hidden" name="contractBillingUpdateListJson" />
			    <input type="hidden" name="contractBillingInsertListJson" />
			    <input type="hidden" name="contractPaymentUpdateListJson" />
			    <input type="hidden" name="contractPaymentInsertListJson" />
			    <input type="hidden" name="partnerUpdateListJson" />
			    <input type="hidden" name="partnerDetailUpdateListJson" />
          </form>
        </div>

      </div>
    </div>

    
  </div>
	<div class="am-margin">
	
     	<button type="submit" onclick="project.submitImplForm();" class="am-btn am-btn-secondary">提交保存</button>
     	<button type="button" onclick="project.revokeProjectAdmin();" class="am-btn am-btn-secondary">废除</button>
	    <button type="button" id="repairButton" class="am-btn am-btn-secondary" onclick="project.toRepairPage();" 
	    	<c:if test="${'N' == project.isRepair || null == project.isRepair}">style="display: none;"</c:if> >运维</button>
      	
		<!-- 错误提示信息 -->
		<input type="hidden" id="error" value="${error}"/>
		<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
		  <div class="am-modal-dialog">
		    <div class="am-modal-hd">错误信息</div>
		    <div id ="errorMsg" class="am-modal-bd">
		     ${error}
		    </div>
		    <div class="am-modal-footer">
		      <span class="am-modal-btn">确定</span>
		    </div>
		  </div>
		</div>

	</div>
    </div>	
		<!-- ***** 分离出去 动态加载 end ***** -->
	</div>
	<!-- content end -->
</div>

<script type="text/javascript">
//初始化倒计时
var count = 5;

var countdown = null;

$(function() {
	
	if("" != $('#error').val()){
		var $modal1 = $('#my-alert');
		$modal1.modal();
	}
    
	var $modal = $('#your-modal');
    $("#doFinishProject").on('click', function(e) {
    	
    	var bilcount = 0;
		$("input[name=billingRate]").each(function(i, v){
			bilcount = parseInt(bilcount) + parseInt(this.value);
		});
		if(bilcount>100){
			$('#errorMsg').html("开票比例总和不能超过100%");
			var $modal1 = $('#my-alert');
			$modal1.modal();
			return false;
		}
		var paycount = 0;
		$("input[name=paymentRate]").each(function(i, v){
			paycount = parseInt(paycount) + parseInt(this.value);
		});
		if(paycount>100){
			$('#errorMsg').html("收款比例总和不能超过100%");
			var $modal1 = $('#my-alert');
			$modal1.modal();
			return false;
		}
    	
    	clearInterval(countdown);
    	//初始化倒计时
      	count = 5;
      	$("#time").html(count);
        //打开窗口
        $modal.modal();
        
        countdown = setInterval(CountDown, 1000);
        function CountDown() {
            $("#time").html(count);
            if (count == 0) {
            	$('#btn_ok').removeAttr("disabled");
                clearInterval(countdown);
            }
            count--;
        }
    });
    
    $('#close').click(function () {
    	$('#btn_ok').attr("disabled","disabled");
        $modal.modal('close');
    });
    
    $('#btn_ok').click(function () {
    	project.projectFinish();
    	$modal.modal('close');
        
    });
    
    $('#isRepair').click(function () {
    	$('#repair').show();
    	$('#repairButton').show();
    });
    $('#isNotRepair').click(function () {
    	$('#repairStartDate').val("");
    	$('#repairEndDate').val("");
    	$('#repair').hide();
    	$('#repairButton').hide();
    });
    
});


</script>
<script id="tpl-tableBilling" type="text/x-handlebars-template">
	<tr x-insert>
      	<td hidden>
			<input type="hidden" name="contractDetailId"  />
			
		</td>
		<td>
      		<label class="am-checkbox">
	      		<input type="checkbox" name="isBilling" value="" data-am-ucheck >
		    </label>
		</td>
		<td>
			<select data-am-selected="{btnSize: 'sm',dropUp: 1}" name="billingType">
				<option value="">请选择</option> 
				<c:forEach items="${billingTypeMap }" var = "billing" >
					 <option value="${billing.key }" <c:if test="${billing.key == partnerDetail.billingType}">selected</c:if>>${billing.value}</option>
				</c:forEach>
			</select>
         </td>
         <td>
       		<div class="am-u-md-12">
       			<input type="date" name="billingDate" class="am-form-field am-input-sm"  placeholder="时间">
       		</div>
       	 </td> 
		<td>
     		<div class="am-u-md-12">
     			<input type="number" name="billingMoney" class="am-input-sm" value="" placeholder="请输入数字" min="0">
     		</div>
     	</td>
		<td>
     		<div class="am-u-md-10">
     			<input type="text" name="billingRate" class="am-input-sm" value=""  min="0" disabled>
     		</div>
     	</td>
	</tr> 
</script>
<script id="tpl-tablePayment" type="text/x-handlebars-template">
	<tr x-insert>
      	<td hidden>
			<input type="hidden" name="contractDetailId"  />
		</td>
       	<td>
         <label class="am-checkbox">
	      	<input type="checkbox"  name="isPayment"  data-am-ucheck >
	    </label>
		</td>
       	<td>
       		<div class="am-u-md-10">
     			<input type="date" name="paymentDate"  class="am-form-field am-input-sm"  placeholder="时间">
     		</div>
       	</td>
		<td>
     		<div class="am-u-md-10">
     			<input type="number" name="paymentRate" class="am-input-sm" value="" placeholder="请输入100以内的数字" min="0">
     		</div>
     	</td>
	</tr> 
</script>
<script id="tpl-table3" type="text/x-handlebars-template">
<tr>
	<td hidden>${partnerCompanyId}</td>
	<td>
		<select id="partnerCompanyId" name="partnerCompanyId" onchange="getPartnerProductAndContact($(this))">
			<option value="">请选择供应商</option>
			<c:forEach items="${partnerCompanyList}" var = "partnerCompany" >
				<option value="${partnerCompany.partnerCompanyId}">${partnerCompany.partnerCompanyName}</option>
			</c:forEach>
		</select>
	</td>
	<td width="25%">
		<!-- 产品/服务 -->
		<select id="partnerProductId" name="partnerProductId">
			<option value="">请选择</option>
		</select>
	</td>
	<td width="25%">
		<!-- 供应商联系人 -->
		<select id="partnerContactId" name="partnerContactId">
			<option value="">请选择</option>
		</select>
	</td>
	<td>
		<button name="removeTr" onclick="$(this).parent().parent().remove();" type="button" class="am-btn am-btn-default am-btn-sm">删除</button>
	</td>
</tr>
</script>
</body>
</html>